package com.zzy.chapter4.ticket.director;

import com.zzy.chapter4.ticket.builder.CompanyTicketBuilder;
import com.zzy.chapter4.ticket.builder.PersonalTicketBuilder;
import org.springframework.stereotype.Component;

@Component
public class Director extends AbstractDirector {
    @Override
    Object buildTicket(String type, String product, String content, String title, String bankInfo, String taxId) {
        switch(type) {
            case "personal":
                PersonalTicketBuilder personalTicketBuilder = new PersonalTicketBuilder();
                personalTicketBuilder.setCommonInfo(title, product, content);
                return personalTicketBuilder.buildTicket();
            case "company":
                CompanyTicketBuilder companyTicketBuilder = new CompanyTicketBuilder();
                companyTicketBuilder.setCommonInfo(title, product, content);
                companyTicketBuilder.setBankInfo(bankInfo);
                companyTicketBuilder.setTaxId(taxId);
                return companyTicketBuilder.buildTicket();
            default:
                return null;
        }
    }
}
